#!/bin/bash

# 涂色抢地盘游戏 - 后端启动脚本 (Linux/Mac)
MODE=${1:-normal}  # 默认模式为 normal

echo "🎯 涂色抢地盘游戏 - 后端启动工具"
echo "================================================"

# 设置环境变量
case $MODE in
    "normal")
        echo "🚀 正常启动模式"
        echo "   - 跳过数据库迁移"
        echo "   - 跳过种子数据"
        export FORCE_MIGRATION=false
        export FORCE_SEED=false
        ;;
    
    "migrate")
        echo "🔄 迁移模式"
        echo "   - 强制应用数据库迁移"
        echo "   - 跳过种子数据"
        export FORCE_MIGRATION=true
        export FORCE_SEED=false
        ;;
    
    "seed")
        echo "🌱 种子数据模式"
        echo "   - 跳过数据库迁移"
        echo "   - 强制添加种子数据"
        export FORCE_MIGRATION=false
        export FORCE_SEED=true
        ;;
    
    "full")
        echo "🔧 完整初始化模式"
        echo "   - 强制应用数据库迁移"
        echo "   - 强制添加种子数据"
        export FORCE_MIGRATION=true
        export FORCE_SEED=true
        ;;
    
    *)
        echo "❌ 未知的启动模式: $MODE"
        echo "可用模式:"
        echo "  - normal: 正常启动（推荐）"
        echo "  - migrate: 仅迁移数据库"
        echo "  - seed: 仅添加种子数据"
        echo "  - full: 完整初始化"
        echo ""
        echo "示例:"
        echo "  ./start-backend.sh"
        echo "  ./start-backend.sh migrate"
        exit 1
        ;;
esac

echo ""
echo "🚀 启动后端服务..."
echo "按 Ctrl+C 停止服务"
echo ""

# 启动后端服务
dotnet run --project src/TerritoryGame.API
